<?php
	class Model_Content {
		public static function getPage($page) {
			$db = Database::getInstance();

			$page_esc = $db->escape($page);

			$result         = $db->fetch($db->query("SELECT * FROM `content` WHERE `page`='{$page_esc}'"));
			$result['page'] = $page;

			return $result;
		}

		public static function setPage($page, $title, $keywords, $description, $content) {
			$db = Database::getInstance();

			$page        = $db->escape($page);
			$title       = $db->escape($title);
			$keywords    = $db->escape($keywords);
			$description = $db->escape($description);
			$content     = $db->escape($content);

			$db->query("INSERT INTO `content` SET
					`page` = '{$page}',
					`title` = '{$title}',
					`keywords` = '{$keywords}',
					`description` = '{$description}',
					`content` = '{$content}'
				ON DUPLICATE KEY UPDATE
					`title` = VALUES(`title`),
					`keywords` = VALUES(`keywords`),
					`description` = VALUES(`description`),
					`content` = VALUES(`content`)
			");
		}

		public static function delPage($page) {
			$db = Database::getInstance();

			$page = $db->escape($page);
			$db->query("DELETE FROM `content` WHERE `page`='{$page}'");
		}
	}